// request.js
const BASE_URL = 'https://qawechat.changanchangan.com/prod-question-api'; // 替换为你的API基础URL
// const BASE_URL = 'http://192.168.1.118:12010';

const request = (url, method = 'GET', data = {}, header = {}) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: `${BASE_URL}${url}`,
      method,
      data,
      header: {
        'Content-Type': 'application/json',
        ...header,
      },
      success: (res) => {
        // 根据返回的状态码进行处理
        if (res.statusCode === 200) {
          resolve(res.data);
        } else {
          reject(res);
        }
      },
      fail: (err) => {
        reject(err);
      },
    });
  });
};

export default request;